package com.asman.vr.dto

import com.asman.vr.network.Api
import retrofit2.Call
import java.util.concurrent.Executor

class RecordDataSource(
        private val api: Api,
        private val projectId: Long,
        private val sort: Int,
        private val pageSize: Int,
        retryExecutor: Executor
) : BaseItemKeyedDataSource<RecordListData>(retryExecutor) {

    override fun queryTop(
        params: LoadInitialParams<String>, pageNo: Int
    ): Call<BaseRes<ListResult<RecordListData>>> {
        return api.getRecodeList(
            projectId = projectId, sort = sort, pageNo = pageNo, pageSize = pageSize
        )
    }

    override fun queryAfter(
        params: LoadParams<String>, pageNo: Int
    ): Call<BaseRes<ListResult<RecordListData>>> {
        return api.getRecodeList(
            projectId = projectId, sort = sort, pageNo = pageNo, pageSize = pageSize
        )
    }

    override fun getKey(item: RecordListData): String = item.id.toString()
}